package com.promis.party.ui.partywork;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.promis.party.R;
import com.promis.party.helper.ContextHelper;
import com.promis.party.ui.home.homebanner.answerwall.MyAnswerActivity;
import com.promis.party.ui.home.homebanner.questionwall.MyQuestionsActivity;
import com.promis.party.ui.partywork.dailywork.agencydoucument.AgencyDoucumentActivity;
import com.promis.party.ui.partywork.dailywork.assessment.AssessmentActivity;
import com.promis.party.ui.partywork.dailywork.count.AssessmentCountActivity;
import com.promis.party.ui.partywork.dailywork.selfevaluation.EvaluationActivity;
import com.promis.party.ui.partywork.dailywork.task.TaskActivity;
import com.promis.party.ui.partywork.dailywork.taskassignment.TaskAssignmentActivity;
import com.promis.party.ui.partywork.dailywork.tracking.TrackingSuperviseActivity;
import com.promis.party.ui.partywork.dailywork.documentfile.DocumentListActivity;
import com.promis.party.ui.partywork.organizeMag.appointment.AppointmentActivity;
import com.promis.party.ui.partywork.organizeMag.organizeQuery.OrganizeQueryActivity;
import com.promis.party.ui.partywork.organizeMag.partyDues.DuesActivity;
import com.promis.party.ui.partywork.organizeMag.relation.RelationTransferActivity;
import com.promis.party.ui.partywork.partyMag.develop.PartyDevelopActivity;
import com.promis.party.ui.partywork.partyMag.flow.PartyFlowActivity;
import com.promis.party.ui.partywork.partyMag.partymembership.PartyMemberShipActivity;
import com.promis.party.ui.partywork.questionwall.StatisticsActivity;
import com.promis.widget.ImageTextView;

/**
 * Created by zcy on 2018/9/25.
 */

public class PartyWorkManagerFragment extends Fragment {

    private ContextHelper contextHelper;

    private ImageTextView imgvAssessment;           // 绩效考核
    private ImageTextView imgvPartyDues;            // 党费缴纳
    private ImageTextView imgvDocumentFile;         // 公文归档
    private ImageTextView imgvRelationTrans;        // 关系转接
    private ImageTextView imgvWallStatistics;       // 问题墙-统计
    private ImageTextView imgvPartyDevelop;         // 党员发展
    private ImageTextView imgvPartyFlow;            // 流动党员
    private ImageTextView imgvSelfEva;              // 绩效自评
    private ImageTextView imgvCount;                // 考核统计
    private ImageTextView imgvQuery;                // 组织查询
    private ImageTextView imgvAgencyDocument;
    private ImageTextView imgvTaskAssignment;
    private ImageTextView imgvTask;
    private ImageTextView imgvTrackingSupervise;
    private ImageTextView imgvQuestionsWall;
    private ImageTextView imgvAnswersWall;
    private ImageTextView imgvPartyMemberShip;
    private ImageTextView imgvAppointment;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        FrameLayout rootLayout = (FrameLayout) inflater.inflate(R.layout.fragment_partywork_manager, container, false);

        imgvAssessment = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_jixiaokaohe);
        imgvAgencyDocument = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_daibangongwen);
        imgvTaskAssignment = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_daily_renwujiaoban);
        imgvTask = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_mubiaorenwu);
        imgvTrackingSupervise = rootLayout.findViewById(R.id.frament_partywork_manager_txtv_genzongducha);
        imgvQuestionsWall = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_wentiqiang);
        imgvAnswersWall = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_huiyinbi);
        imgvPartyMemberShip = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_dangjiguanli);
        imgvPartyDues = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_dangfeijiaona);
        imgvDocumentFile = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_gongwenguidang);
        imgvWallStatistics = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_tongji);
        imgvRelationTrans = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_guanxizhuanjie);
        imgvPartyDevelop = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_dangyuanfazhan);
        imgvPartyFlow = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_liudongdangyuan);
        imgvAppointment = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_ganburenmian);
        imgvSelfEva = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_jixiaoziping);
        imgvCount = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_kaihetongji);
        imgvQuery = rootLayout.findViewById(R.id.fragment_partywork_manager_txtv_zuzhichaxun);

        initData();
        initListener();
        return rootLayout;
    }

    private void initData() {
        contextHelper = new ContextHelper(getContext());
    }

    private void initListener() {
        imgvAgencyDocument.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), AgencyDoucumentActivity.class);
                startActivity(intent);
            }
        });

        imgvTaskAssignment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), TaskAssignmentActivity.class);
                startActivity(intent);
            }
        });

        imgvTask.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), TaskActivity.class);
                startActivity(intent);
            }
        });

        imgvTrackingSupervise.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), TrackingSuperviseActivity.class);
                startActivity(intent);
            }
        });

        imgvQuestionsWall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), MyQuestionsActivity.class);
                startActivity(intent);
            }
        });

        imgvAnswersWall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), MyAnswerActivity.class);
                startActivity(intent);
            }
        });

        imgvAssessment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(),AssessmentActivity.class));
            }
        });

        imgvPartyDues.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(),DuesActivity.class));
            }
        });

        imgvDocumentFile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(),DocumentListActivity.class));
            }
        });

        imgvWallStatistics.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(),StatisticsActivity.class));
            }
        });

        imgvRelationTrans.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(),RelationTransferActivity.class));
            }
        });

        imgvPartyMemberShip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), PartyMemberShipActivity.class);
                startActivity(intent);
            }
        });
        imgvPartyDevelop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), PartyDevelopActivity.class);
                startActivity(intent);
            }
        });
        imgvPartyFlow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), PartyFlowActivity.class);
                startActivity(intent);
            }
        });
        imgvAppointment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), AppointmentActivity.class);
                startActivity(intent);
            }
        });
        imgvSelfEva.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), EvaluationActivity.class);
                startActivity(intent);
            }
        });
        imgvCount.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), AssessmentCountActivity.class);
                startActivity(intent);
            }
        });
        imgvQuery.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getContext(), OrganizeQueryActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            switch (requestCode) {
//                case RequestCode.CITY : LetterSortActivity.Helper.onActivityResult(data, txtvCity); break;
//                case RequestCode.PETSELFISH :findOwnerPet(); break;
            }
        }
    }

    @Override
    public void onResume() {
        super.onResume();
    }

//    public void httpFindDynamicList() {
//        HttpJsonParams params = new HttpJsonParams();
//        params.add("interest",1);
//        if (UserPreferences.getInstance(getContext()).exists()) {
//            params.add("userId", UserPreferences.getInstance(getContext()).getId());
//        }
//        String url = contextHelper.getServiceUrl(R.string.findInterestDynamicList);
//        new HttpClient<JsonList<Dynamic>>(getContext()) {
//            @Override
//            protected void onSuccess(JsonList<Dynamic> result) {
//                dynamicList = result.getDataList();
//                adptAdopt.notifyDataSetChanged(dynamicList);
//            }
//        }.postAsyn(url, params);
//    }
}